Currently GTK can be built with G_ENABLE_DEBUG which enables various debug code and parsing
of those env vars, or without, which instead of parsing them prints a warning if they are set.
While building with G_ENABLE_DEBUG isn't strictly needed it's the only way to make GTK_DEBUG=interactive work,
which is a nice thing to have always.
This enables parsing of those env vars in any case and allows specific values being marked as also
available when not built with G_ENABLE_DEBUG (interactive for example). If not built with G_ENABLE_DEBUG
then all unavailable values will be marked as such in the help output and a note is added that
GTK needs to be built with G_ENABLE_DEBUG to use them, which should help discoverability.
### GTK_DEBUG {#GTK_Debug-Options}
-Unless GTK has been configured with `-Ddebug=false`, this variable
-can be set to a list of debug options, which cause GTK to print out
-different types of debugging information.
+This variable can be set to a list of debug options, which cause GTK to
+print out different types of debugging information. Some of these options
+are only available when GTK has been configured with `-Ddebug=true`.
actions
: Actions and menu models
### GDK_DEBUG
-Unless GTK has been configured with `-Ddebug=false`, this variable
-can be set to a list of debug options, which cause GDK to print out
-different types of debugging information.
+This variable can be set to a list of debug options, which cause GDK to
+print out different types of debugging information. Some of these options
+are only available when GTK has been configured with `-Ddebug=true`.
cursor
: Information about cursor objects (only win32)
### GSK_DEBUG {#GSK-Debug-Options}
-Unless GTK has been configured with `-Ddebug=false`,
-this variable can be set to a list of debug options,
-which cause GSK to print out different types of debugging
-information.
+This variable can be set to a list of debug options, which cause GSK to
+print out different types of debugging information. Some of these options
+are only available when GTK has been configured with `-Ddebug=true`.
renderer
: General renderer information
const char *key;
guint value;
const char *help;
+ gboolean always_enabled;
} GdkDebugKey;
guint gdk_parse_debug_var (const char *variable,
* 0 otherwise.
*/
-#ifdef G_ENABLE_DEBUG
static const GdkDebugKey gdk_debug_keys[] = {
{ "misc", GDK_DEBUG_MISC, "Miscellaneous information" },
{ "events", GDK_DEBUG_EVENTS, "Information about events" },
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer" },
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings" },
};
-#endif
#ifdef G_HAS_CONSTRUCTORS
const char *q;
gboolean invert;
gboolean help;
+ gboolean debug_enabled;
+
+#ifdef G_ENABLE_DEBUG
+ debug_enabled = TRUE;
+#else
+ debug_enabled = FALSE;
+#endif
string = g_getenv (variable);
if (string == NULL)
}
else
{
+ char *val = g_strndup (p, q - p);
for (i = 0; i < nkeys; i++)
{
if (strlen (keys[i].key) == q - p &&
g_ascii_strncasecmp (keys[i].key, p, q - p) == 0)
{
+ if (!debug_enabled && !keys[i].always_enabled)
+ {
+ fprintf (stderr, "\"%s\" is only available when building GTK with G_ENABLE_DEBUG. See %s=help\n",
+ val, variable);
+ break;
+ }
result |= keys[i].value;
break;
}
}
if (i == nkeys)
- {
- char *val = g_strndup (p, q - p);
- fprintf (stderr, "Unrecognized value \"%s\". Try %s=help\n", val, variable);
- g_free (val);
- }
+ fprintf (stderr, "Unrecognized value \"%s\". Try %s=help\n", val, variable);
+ g_free (val);
}
p = q;
max_width += 4;
fprintf (stderr, "Supported %s values:\n", variable);
- for (i = 0; i < nkeys; i++)
- fprintf (stderr, " %s%*s%s\n", keys[i].key, (int)(max_width - strlen (keys[i].key)), " ", keys[i].help);
+ for (i = 0; i < nkeys; i++) {
+ fprintf (stderr, " %s%*s%s", keys[i].key, (int)(max_width - strlen (keys[i].key)), " ", keys[i].help);
+ if (!debug_enabled && !keys[i].always_enabled)
+ fprintf (stderr, " [unavailable]");
+ fprintf (stderr, "\n");
+ }
fprintf (stderr, " %s%*s%s\n", "all", max_width - 3, " ", "Enable all values");
fprintf (stderr, " %s%*s%s\n", "help", max_width - 4, " ", "Print this help");
fprintf (stderr, "\nMultiple values can be given, separated by : or space.\n");
+ if (!debug_enabled)
+ fprintf (stderr, "Values marked as [unavailable] are only accessible if GTK is built with G_ENABLE_DEBUG.\n");
}
if (invert)
guint all_flags = 0;
for (i = 0; i < nkeys; i++)
- all_flags |= keys[i].value;
+ {
+ if (debug_enabled || keys[i].always_enabled)
+ all_flags |= keys[i].value;
+ }
result = all_flags & (~result);
}
gdk_ensure_resources ();
-#ifdef G_ENABLE_DEBUG
_gdk_debug_flags = gdk_parse_debug_var ("GDK_DEBUG",
gdk_debug_keys,
G_N_ELEMENTS (gdk_debug_keys));
-#else
- if (g_getenv ("GDK_DEBUG"))
- g_warning ("GDK_DEBUG set but ignored because GTK isn't built with G_ENABLE_DEBUG");
-#endif /* G_ENABLE_DEBUG */
#ifndef G_HAS_CONSTRUCTORS
stash_desktop_startup_notification_id ();
#include "gskdebugprivate.h"
#include "gdk/gdk-private.h"
-#ifdef G_ENABLE_DEBUG
static const GdkDebugKey gsk_debug_keys[] = {
{ "renderer", GSK_DEBUG_RENDERER, "General renderer information" },
{ "cairo", GSK_DEBUG_CAIRO, "Cairo renderer information" },
{ "vulkan-staging-image", GSK_DEBUG_VULKAN_STAGING_IMAGE, "Use a staging image for Vulkan texture upload" },
{ "vulkan-staging-buffer", GSK_DEBUG_VULKAN_STAGING_BUFFER, "Use a staging buffer for Vulkan texture upload" }
};
-#endif
static guint gsk_debug_flags;
static void
init_debug_flags (void)
{
-#ifdef G_ENABLE_DEBUG
static volatile gsize gsk_debug_flags__set;
if (g_once_init_enter (&gsk_debug_flags__set))
g_once_init_leave (&gsk_debug_flags__set, TRUE);
}
-#endif
}
gboolean
return (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0;
}
-#ifdef G_ENABLE_DEBUG
static const GdkDebugKey gtk_debug_keys[] = {
{ "keybindings", GTK_DEBUG_KEYBINDINGS, "Information about keyboard shortcuts" },
{ "modules", GTK_DEBUG_MODULES, "Information about modules and extensions" },
{ "builder", GTK_DEBUG_BUILDER, "Trace GtkBuilder operation" },
{ "builder-objects", GTK_DEBUG_BUILDER_OBJECTS, "Log unused GtkBuilder objects" },
{ "no-css-cache", GTK_DEBUG_NO_CSS_CACHE, "Disable style property cache" },
- { "interactive", GTK_DEBUG_INTERACTIVE, "Enable the GTK inspector" },
+ { "interactive", GTK_DEBUG_INTERACTIVE, "Enable the GTK inspector", TRUE },
{ "touchscreen", GTK_DEBUG_TOUCHSCREEN, "Pretend the pointer is a touchscreen" },
{ "snapshot", GTK_DEBUG_SNAPSHOT, "Generate debug render nodes" },
{ "accessibility", GTK_DEBUG_A11Y, "Information about accessibility state changes" },
};
-#endif /* G_ENABLE_DEBUG */
/* This checks to see if the process is running suid or sgid
* at the current time. If so, we don’t allow GTK to be initialized.
gdk_pre_parse ();
-#ifdef G_ENABLE_DEBUG
debug_flags[0].flags = gdk_parse_debug_var ("GTK_DEBUG",
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
any_display_debug_flags_set = debug_flags[0].flags > 0;
-#else
- if (g_getenv ("GTK_DEBUG"))
- g_warning ("GTK_DEBUG set but ignored because GTK isn't built with G_ENABLE_DEBUG");
-#endif /* G_ENABLE_DEBUG */
env_string = g_getenv ("GTK_SLOWDOWN");
if (env_string)